import request from "@/utils/request";
import { getParamsSuffix } from "@/utils/paramsUtils";
import { instanceOf } from "prop-types";


/**
 * 分页
 * @param params
 * @returns {Promise<any>}
 */
export async function listAllTableData(params) {
    return request('/api/cdcerservice/v1/cerSysteminitImportInfo/listAllTableData', {
        method: 'POST',
        requestType: 'form',
        data: { ...params },
    });
}

// 自测表导出
export async function exportSelfTestTable(params) {
    return request(`/api/cdcerserver/v1/cerSysteminitImportInfo/exportSelfTestTable`, {
        method: 'POST',
        requestType: 'form',
        responseType: 'blob',
        data: {
            ...params
        }
    });
}



/**
 * 添加
 * @param params
 * @returns {Promise<any>}
 */
export async function addData(params) {
    return request('/api/cdcerserver/v1/cerSysteminitImportInfo/addData', {
        method: 'POST',
        requestType: 'form',
        data: { ...params },
    });
}

/**
 * 人员查询姓名和身份证
 * @param params
 * @returns {Promise<any>}
 */
export async function queryPersonInfoByNameOrIdCard(params) {
    return request('/api/cdcerserver/v1/cerpersoninfo/queryPersonInfoByNameOrIdCard', {
        method: 'POST',
        requestType: 'form',
        data: { ...params },
    });
}

/**
 * 修改
 * @param params
 * @returns {Promise<any>}
 */
export async function updateRecord(params) {
    return request('/api/cdcerservice/v1/initialdatareporting/updateRecord', {
        method: 'POST',
        requestType: 'form',
        data: { ...params },
    });
}

/**
 * 详情
 * @param query
 * @returns {Promise<any>}
 */
export async function findById(query) {
    const params = getParamsSuffix(query);
    return request(`/api/cdcerservice/v1/initialdatareporting/findById?${params}`);
}

/**
* 字典
* @param query
* @returns {Promise<any>}
*/
export async function findAllDictName(query) {
    const params = getParamsSuffix(query);
    return request(`/api/cdcerservice/v1/sysDict/findAllDictName?${params}`);
}

/**
 * 正式库
 * @param query
 * @returns {Promise<any>}
 */
export async function insertOfficeInfo(query) {
    const params = getParamsSuffix(query);
    return request(`/api/cdcerservice/v1/cerSysteminitImportOfficialInfo/insertOfficeInfo?${params}`);
}



/**
 * 点击导出所有信息
 * @returns {Promise<any>}
 * @param params
 */
export async function newQueryAllExportData(params) {
    return request(`/api/cdcerservice/v1/cerSysteminitImportInfo/newQueryAllExportData`, {
        method: 'POST',
        requestType: 'form',
        responseType: 'blob',
        data: {
            ...params
        }
    });
}


export async function deleteById(params) {


    return request('/api/cdcerservice/v1/cerSysteminitImportInfo/del?id=' + params.id, {
        method: 'GET',

    });
}

/**
 * 数据上报-新增：根据姓名和身份证号查询绑定村集合
 * @param params
 * @returns {Promise<any>}
 */
export async function getVillagesByNameOrIdCard(params) {
    return request('/api/cdcerserver/v1/cerpersoninfo/getVillagesByNameOrIdCard', {
        method: 'POST',
        requestType: 'form',
        data: { ...params },
    });
}


/**
 * 数据推送至国家平台
 * @param params
 * @returns {Promise<any>}
 */
export async function pushNation(params) {
    let ids = []
    for (const key in params) {
        ids.push(params[key])
    }
    return request('/api/cdcerserver/v1/cerSysteminitImportInfo/pushNation', {
        method: 'POST',
        data: ids,
    });
}